#include<iostream>
using namespace std;
const int N=100010;
int n=0,k=0;
int q[N];
int quicksort(int k,int left,int right)
{
    if(left>=right)return q[left];
    int i=left-1,j=right+1;
    int mid=q[left];
    while(i<j)
    {
        while(q[++i]<=mid);
        while(q[--j]>mid);
        if(i<j)swap(q[i],q[j]);
    }
    int s=j-left+1;
    if(k<=s)return quicksort(k,left,j);
    else return quicksort(k-s,j+1,right);
}    
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>q[n];
    cout<<quicksort(k,0,n-1);
}